package com.lzy.service.impl;

import com.lzy.mapper.busMapper;
import com.lzy.pojo.bus;
import com.lzy.service.busService;
import com.lzy.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

public class busServiceImpl implements busService {
    SqlSessionFactory factory = SqlSessionFactoryUtils.getSqlSessionFactory();

    @Override
    public bus select(String bus_num) {
        SqlSession sqlSession = factory.openSession();
        busMapper mapper = sqlSession.getMapper(busMapper.class);
        bus bus = mapper.select(bus_num);
        sqlSession.close();
        return bus;
    }

    @Override
    public List<bus> selectAll() {
        SqlSession sqlSession = factory.openSession();
        busMapper mapper = sqlSession.getMapper(busMapper.class);
        List<bus> buses = mapper.selectAll();
        sqlSession.close();
        return buses;
    }

    @Override
    public List<bus> selectByNums(List<String> nums) {
        SqlSession sqlSession = factory.openSession();
        busMapper mapper = sqlSession.getMapper(busMapper.class);
        List<bus> buses = mapper.selectByNums(nums);
        return buses;
    }
}
